package com.sky.mapper.user;

import com.sky.pojo.AddressBook;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserAddressBookMapper{
    void addAddressBook(AddressBook addressBook);

    @Select("select * from address_book where user_id=#{userId}")
    List<AddressBook> findAll(Long userId);

    @Select("select * from address_book where is_default=#{enable} and user_id=#{currentId}")
    List<AddressBook> findDefault(Integer enable, Long currentId);

    @Select("select * from address_book where id=#{id}")
    AddressBook findById(Long id);

    void updateAddressBook(AddressBook addressBook);

    @Delete("delete from address_book where id=#{id}")
    void delById(Long id);

    @Update("update address_book set is_default=0 where user_id=#{currentId}")
    void updateIsDefault(Long currentId);
}
